package com.yc.io.niodemo.chat;

/**
 * 消息类型枚举
 *
 * @author samuelchen
 * @version 1.0
 * @date 2022-04-15
 */
public enum MessageType {

    /**/
    REG_SERVER_SYN("reg_server_syn"),
    CHAT_MSG_SEND("chat_send"),
    CHAT_MSG_RECEIVE("chat_receive"),
    UNKNOWN("unknown"),
    REG_SERVER_ACK("reg_server_ack"),
    REG_CLIENT_ACK("reg_client_ack"),
    BROADCAST_USER_LIST("broadcast_user_list");

    private String action;

    MessageType(String action) {
        this.action = action;
    }

    public String getAction() {
        return action;
    }

    public static MessageType getActionType(String action) {
        for (MessageType messsageType : MessageType.values()) {
            if (messsageType.getAction().equals(action)) {
                return messsageType;
            }
        }
        return UNKNOWN;
    }
}
